﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Jäckvik_Grupp4
{
    public partial class CLRS_Inloggning : Form
    {
        LOGIC.LogicStaff staff = new LOGIC.LogicStaff();
        
        public CLRS_Inloggning()
        {
            InitializeComponent();
        }

        private void button_Login_Click(object sender, EventArgs e)
        {
            try
            {
                if (staff.LogIn(Convert.ToInt32(textBox_LoginUserId.Text), textBox_LoginPass.Text) == true)
                {
                    int tempId = int.Parse(textBox_LoginUserId.Text);
                    staff = LOGIC.LogicStaff.CheckLevel(tempId);
                    if (staff.Behörighet == "1") 
                    {                         
                        Lodging l = new Lodging();
                        l.Show();
                        textBox_LoginPass.Clear();
                        textBox_LoginUserId.Clear();                     
                    }
                    else if (staff.Behörighet == "2")
                    {
                        
                        Skishop s = new Skishop();
                        s.Show();
                        textBox_LoginPass.Clear();
                        textBox_LoginUserId.Clear();
                    }
                    else if (staff.Behörighet == "3")
                    {                        
                        Admin a = new Admin();
                        a.Show();
                        textBox_LoginPass.Clear();
                        textBox_LoginUserId.Clear();
                    }
                    else if (staff.Behörighet == "4")
                    {
                        
                        Admin a = new Admin();
                        a.Show();
                        textBox_LoginPass.Clear();
                        textBox_LoginUserId.Clear();
                    }
                }
                else
                {
                        MessageBox.Show("Fel användarnamn/lösenord");
                }
            }
            catch
            {
                MessageBox.Show("Felaktig inmatning");
            }
                
        }
    }
}
